<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>登录页面</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/css/bootstrap.min.css" integrity="sha384-xOolHFLEh07PJGoPkLv1IbcEPTNtaed2xpHsD9ESMhqIYd0nLMwNLD69Npy4HI+N" crossorigin="anonymous">
    <script th:src="@{/js/jquery-3.1.1.js}"></script>
    <style>
        body {
            background: linear-gradient(135deg, #71b7e6, #9b59b6);
            display: flex;
            justify-content: center;
            align-items: center;
            min-height: 100vh;
            margin: 0;
        }

        .login-container {
            max-width: 400px;
            background-color: rgba(255, 255, 255, 0.9);
            padding: 30px;
            border-radius: 15px;
            box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
        }

        .form-group label {
            font-weight: 600;
            color: #333;
        }

        .form-control {
            border-radius: 8px;
            border: 1px solid #ccc;
            padding: 10px 15px;
            transition: border-color 0.3s ease;
        }

        .form-control:focus {
            border-color: #71b7e6;
            box-shadow: 0 0 0 0.2rem rgba(113, 183, 230, 0.25);
        }

        .btn-primary {
            background-color: #71b7e6;
            border-color: #71b7e6;
            border-radius: 8px;
            padding: 10px;
            font-weight: 600;
            transition: background-color 0.3s ease;
        }

        .btn-primary:hover {
            background-color: #5a9bc2;
            border-color: #5a9bc2;
        }

        .text-center a {
            color: #71b7e6;
            text-decoration: none;
            transition: color 0.3s ease;
        }

        .text-center a:hover {
            color: #5a9bc2;
        }
    </style>
</head>

<body>
<div class="login-container">
    <h2 class="text-center mb-4">用户登录</h2>
    <form>
        <div class="form-group">
            <label for="username">用户名</label>
            <input type="text" class="form-control" id="username" placeholder="请输入用户名">
        </div>
        <div class="form-group">
            <label for="password">密码</label>
            <input type="password" class="form-control" id="password" th:autocomplete="off" placeholder="请输入密码">
        </div>
        <div style="width: 100px;height: 30px">
            <span th:text="${msg}" style="color: red"></span>
        </div>
        <button type="submit" id="log" class="btn btn-primary btn-block">登录</button>
    </form>
    <div class="text-center mt-3">
        <a href="#">忘记密码?</a>
    </div>
</div>
<script>

    $("#log").click(function () {
        var user = {
            username:$("#username").val(),
            password:$("#password").val()
        }
        $.ajax({
            type:"POST",
            url:"/login",
            data:JSON.stringify(user),
            dataType:"json",
            contentType:"application/json",
            success:function (data) {
                window.location.href="/dish/list/1";

            },
            error:function (data) {
                // window.location.href="/"
                console.log(data)

            }
        })
    })
</script>
</body>

</html>